package com.xdf.ecommerce.controller;

import com.xdf.ecommerce.stream.customChannel.MySendService;
import com.xdf.ecommerce.stream.defaultChannel.DefaultSendService;
import com.xdf.ecommerce.vo.SCSMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author chanchaw
 * @create 2025-11-06 16:08
 */
@CrossOrigin
@RestController
@RequestMapping("/msg")
@RequiredArgsConstructor
public class MessageController {
    private final DefaultSendService defaultSendService;
    private final MySendService mySendService;
    // 使用默认信道发送消息
    @PostMapping("/default")
    public void defaultSend(@RequestBody SCSMessage msg){
//        SCSMessage msg = new SCSMessage();
//        msg.setId(11);
//        msg.setProjectName("test spring cloud stream default channel");
//        msg.setAuthor("scs");
//        msg.setOrg("scs");
        defaultSendService.sendMessage(msg);
    }
    // 使用自定义信道发送消息
    @PostMapping("/custom")
    public void mySend(@RequestBody SCSMessage msg){
//        SCSMessage msg = new SCSMessage();
//        msg.setId(11);
//        msg.setProjectName("test spring cloud stream custom channel");
//        msg.setAuthor("chanchaw");
//        msg.setOrg("chanchaw");
        mySendService.sendMessage(msg);
    }
}
